<%@ page language="java"  pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@ include file="/_taglib.jsp" %>
<c:choose> 
<c:when test="${dlgFlag==1}">
				<table class="table" id="lookup-data-table" 
					data-toggle="table"
					data-target="#lookupbackDialog"
					data-page-size="5"
					data-url="sys/user/list" 
                    data-toolbar="#filter-bar"
                    data-show-refresh = "false"
                    data-show-toggle = "false"
                    data-show-columns = "false"
                    data-show-export = "false"
                    data-search-value="${search }"
					data-total-rows="${page.totalRow }"
					data-total-page="${page.totalPage }"
					data-page-number="${page.pageNumber }"
					data-page-size="${page.pageSize }"
					<c:if test="${!empty sort}">data-sort-name="${sort}"</c:if>
					<c:if test="${!empty sort}">data-sort-order="${order}"</c:if>
					>
				    <thead>
					<tr>
						<c:forEach items = "${colFieldMapList}" var = "fieldItem" varStatus="status">
						<th data-field="${fieldItem.field}" data-align="center" data-sortable="true">${fieldItem.fieldName}
						</th>
						</c:forEach>
						<th data-align="center">操作</th>
					</tr>				    
				    </thead>
	                <c:forEach items = "${page.list}" var = "item" varStatus="status">
					<tr>
						<c:forEach items = "${colFieldList}" var = "item1">
						<td><c:out value="${item.get(item1) }"></c:out></td>
						</c:forEach>
						<td>
							<div class="btn-group">
								<button class="btn btn-default bringback" type="button" name="btnBringback" title="选中" 
									backKey="${item.id}" backValue="${item.loginName}">
								<i class="fa fa-check"></i></button>
							</div>						
						</td>
					</tr>
					</c:forEach>				    
				</table>
</c:when>
<c:otherwise>

<%@ include file="/_navbar.jsp" %>

<section class="content">
    <div class="row">
        <div class="col-md-12">    
				<div id="custom-toolbar">
                     <div class="box-body">
                         <div class="row">
                             <div class="col-xs-2">
                                 <input type="text" id="jfk_user__id" op="eq" class="query-field form-control" placeholder="编号" value="${jfk_user__id}">
                             </div>
                             <div class="col-xs-2">
                                 <input type="text" id="jfk_user__loginName" op="like" class="query-field form-control" placeholder="登录名" value="${jfk_user__loginName}">
                             </div>
                             <div class="col-xs-2">
                                 <input type="text" id="jfk_user__realName" op="like" class="query-field form-control" placeholder="真实姓名" value="${jfk_user__realName}">
                             </div>
                             <div class="col-xs-2">
                              	<j:select type="selectEx" dictType="dataStatus" id="jfk_user__status" name="jfk_user__status" isNull="false" label="数据状态"/>
                             </div>
                             <div class="col-xs-2">
                            	<div class="input-group">
	                             	<input type="hidden" id="jfk_user__orgId" class="query-field form-control" op="in" name="user.orgId" value="${jfk_user__orgId}">
	                             	<input type="text" id="f_jfk_user__orgName" name="f_jfk_user__orgName" class="query-field form-control" value="${f_jfk_user__orgName}" placeholder="用户组">
	                             	<span class="input-group-addon" onclick="showMenu(this); return false;"><i class="fa fa-ellipsis-v"></i></span>
								</div>
								<div id="menuContent" class="menuContent" style="display:none; position: absolute;z-index:999">
									<ul id="orgListTree" class="ztree"></ul>
								</div>								
                             </div>
                         </div>
                     </div><!-- /.box-body -->
                     <div class="box-body" style="margin-top:10px">
                         <div class="row">
                             <div class="col-xs-3">
                                 <input type="text" id="jfk_user__email" class="query-field form-control" placeholder="电子邮箱" value="${jfk_user__email}">
                             </div>
                             <div class="col-xs-3">
                                 <input type="text" id="jfk_user__mobile" class="query-field form-control" placeholder="手机号码" value="${jfk_user__mobile}">
                             </div>
                             <div class="col-xs-3">
                             	<div class="input-group">
                                	<div class="input-group-addon">
                                    	<i class="fa fa-calendar"></i>
                                 	</div>
                                  	<input type="text" id="jfk_user__createTime" op="between" class="query-field form-control pull-right date-range" placeholder="创建时间" value="${jfk_user__createTime}"/>
                             	</div><!-- /.input group -->
                             </div>
                             <div class="col-xs-3">
                             	<input type="hidden" id="jfk_user__creator" name="creator" class="query-field" op="eq" value="${jfk_user__creator}">
                             	<div class="input-group">
	                             	<input type="text" id="f_jfk_user__creator" name="f_jfk_user_creator" class="query-field form-control suggest" 
	                             		searchClass="org.jfk.sys.user.User" searchField="loginName" 
	                             		bringbackField="id" placeholder="创建人" op="eq" value="${f_jfk_user__creator}">
	                             	<span class="input-group-addon" lookupUrl="sys/user/list" id="l_jfk_user__creator"><i class="fa fa-ellipsis-v"></i></span>
								</div>
                             </div>
                         </div>
                     </div><!-- /.box-body -->
				</div>

				
				<table class="table" id="data-table" data-toggle="table"
					data-url="sys/user/list" 
					data-del-url="sys/user/del" 
					data-del-all-url="sys/user/delAll" 
					data-add-url="sys/user/edit" 
                    data-toolbar="#custom-toolbar"
                    data-dialog="#dialog"
                    data-search-value="${search }"
					data-total-rows="${page.totalRow }"
					data-total-page="${page.totalPage }"
					data-page-number="${page.pageNumber }"
					data-page-size="${page.pageSize }"
					<c:if test="${!empty sort}">data-sort-name="${sort}"</c:if>
					<c:if test="${!empty sort}">data-sort-order="${order}"</c:if>
					>
				    <thead>
					<tr>
				        <th data-field="state" data-checkbox="true">选择</th>
						<c:forEach items = "${colFieldMapList}" var = "fieldItem" varStatus="status">
						<th data-field="${fieldItem.field}" data-align="center" data-sortable="true">${fieldItem.fieldName}
						</th>
						</c:forEach>
						<th data-align="center">头像</th>
						<th data-align="center">操作</th>
					</tr>				    
				    </thead>
	                <c:forEach items = "${page.list}" var = "item" varStatus="status">
					<tr>
						<td></td>
						<c:forEach items = "${colFieldList}" var = "item1">
							<c:choose>
								<c:when test="${item1=='id'}">
									<td>
										<a href="#" onclick="openDialog('sys/user/edit/${item.id}?backUrl=sys/user/list',null)">
											<c:out value="${item.get(item1) }"></c:out>
										</a>
									</td>
								</c:when>
								<c:otherwise>
									<td><nobr><c:out value="${item.get(item1) }"></c:out></nobr></td>
								</c:otherwise>
							</c:choose>
						</c:forEach>
						<td>
							<img alt="" src='<j:kv key="${item.picture}" column="file_path" table="jfk_attachment_file"/>' height="30">						
						</td>
						<td>
							<div class="btn-group">
							<!-- 
								<button onclick="openDialog('sys/user/edit/${item.id}?backUrl=sys/user/list',null)" class="btn btn-default" type="button" name="edit" title="编辑"><i class="glyphicon glyphicon-pencil"></i></button>
 							-->
								<button onclick="loadAjaxContent('sys/user/edit/${item.id}?backUrl=sys/user/list')" class="btn btn-default" type="button" name="edit" title="编辑"><i class="glyphicon glyphicon-pencil"></i></button>
								
								<button class="btn" type="button" name="del" title="删除" onclick="del('${item.get('id')}');"><i class="glyphicon glyphicon-remove-sign"></i></button>
							</div>						
						</td>
					</tr>
					</c:forEach>				    
				</table>
            </div>
          </div>
    </div>

<div id="dialog"></div>
<div id="filter-bar"></div>

<SCRIPT type="text/javascript">
	<!--
	var setting = {
		check: {
			enable: true,
			chkboxType: {"Y":"s", "N":"s"}
		},	
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onCheck: onCheck
		}
	};

	var zNodes = ${orgList};
	
	function onCheck(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("orgListTree"),
		nodes = zTree.getCheckedNodes(),
		v1 = "";
		v2 = "";
		nodes.sort(function compare(a,b){return a.id-b.id;});
		for (var i=0, l=nodes.length; i<l; i++) {
			v1 += nodes[i].id + ",";
			v2 += nodes[i].name + ",";
		}
		if (v1.length > 0 ) v1 = v1.substring(0, v1.length-1);
		if (v2.length > 0 ) v2 = v2.substring(0, v2.length-1);
		$("#f_jfk_user__orgName").attr("value",v2);
		$("#jfk_user__orgId").attr("value",v1);
		
	}

	function showMenu() {
		var display =$('#menuContent').css('display');
		if(display == 'none'){
			var $this = $(this);
			//$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
			
			//col-xs-3中的相对位置
			$("#menuContent").css({left:15 + "px", top: 34 + "px"}).slideDown("fast");
			$("body").bind("mousedown", onBodyDown);				
		}			
	}
	
	function hideMenu() {
		$("#menuContent").fadeOut("fast");
		$("body").unbind("mousedown", onBodyDown);
	}
	
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}

	$(document).ready(function(){
		var orgListTree = $.fn.zTree.init($("#orgListTree"), setting, zNodes);
		
		console.debug(orgListTree);
		orgListTree.expandAll(true);
		
		var checkedOrg = $("#jfk_user__orgId").val();
		if (checkedOrg && checkedOrg.length > 0){
			var checkedIds = checkedOrg.split(",");
			for (var i = 0 ; checkedOrg.length ; i++){
				var ckNode = orgListTree.getNodeByTId(checkedIds[i]);
				console.debug("ckNode = " +ckNode,"checkedIds[i] = " +checkedIds[i]);
				if (ckNode) {
					orgListTree.checkNode(ckNode,true,false,false);
				}else{
					break;
				}
			}
		}
	});
	//-->
</SCRIPT>



</section>
</c:otherwise>
</c:choose>



<%@ include file="/_list_js.jsp" %>

